﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="frmPuntosRecorridos2.aspx.cs" Inherits="EncuentraWEB.frmPuntosRecorridos2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
     <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAW_vO5gTGD3WOujJaX3VyVhS3OLMgfgRH-fiS7wt-9Lvh34X5rRRKlLui90JJl0aYGoyZqjDDIJ0D1Q"
        type="text/javascript"></script>
      <script type="text/javascript">
           var map;
           var snapToRoute;
           var routeOverlay;
           var lookingGlass;
           var puntos = new Array();
          
           function Inicio() {

               if (GBrowserIsCompatible()) {
                   map = new GMap2(document.getElementById("Map"));
                   map.setCenter(new GLatLng(-32.936135, -60.674550), 15);
                   map.setMapType(G_NORMAL_MAP);
                   map.addControl(new GLargeMapControl());
                   map.addControl(new GOverviewMapControl());
                   puntitos = 0;
                   punLat = 0;
                   punLong = 0;
                   GEvent.addListener(map, "click", tratamiento_clic);
                   Recoridos();
               }

           }
           function tratamiento_clic(overlay, point) {
               var obj = document.getElementById("ctl00_ContentPlaceHolder1_txtRecorrido");
               var url = "ABMPuntos.aspx?puntos=" + point.toString() + "&recorrido=" + obj.value;
               var ventana = window.showModalDialog(url, "width=300, height=50");
               alert(ventana.returnValue);
               //    var btn = document.getElementById("ctl00_ContentPlaceHolder1_Button4");
               //    if (btn) {
               //        btn.click();
               //    }
               //punto = ;
               //alert("El punto donde has hecho clic es: " + point.toString());

           }

           function Recoridos() {
                    
               EjecuarWebServices('http://localhost:49768/ServiceEncuentra.asmx', 'GetXmlRecorridos', 6)
               map.clearOverlays();
               if (document.getElementById("HRecorrido").value.length > 0) {
                   var xmlDoc = GXml.parse(document.getElementById("HRecorrido").value);
                   var posicion = xmlDoc.documentElement.getElementsByTagName("Punto");
                   for (var i = 0; i < posicion.length; i++) {
                       var lat = parseFloat(posicion[i].getAttribute("decLatitud"));
                       var lng = parseFloat(posicion[i].getAttribute("decLongitud"));
                       puntos[i] = new GLatLng(lat, lng);
                       CrearMarca(puntos[i], i, 'PARADA');
                   }
                   routeOverlay = new GPolyline(puntos, '#FF9601', 5, 0.6);
               }
           }

        function CrearMarca(punto, Descripcion, html) {
            var EtpIcon = new GIcon(G_DEFAULT_ICON);
            EtpIcon.shadowSize = new GSize(0, 0);
            markerOptions = { icon: EtpIcon, title: Descripcion }
            var pos = new GMarker(punto, markerOptions);
            map.addOverlay(pos);
        }
        
        
    </script>

</head>
<body onload="javascript:Inicio();">
    <form id="form1" runat="server">
    <input id="HRecorrido" type="hidden" />
      <asp:ScriptManager ID="ScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Path="WebServiceProxy.js" />
        </Scripts>
       
    </asp:ScriptManager>
    <div id="Map">
    
    </div>
    </form>
</body>
</html>
